def binaryToDecimal(binaryString):
    num = 0
    l = len(binaryString)
    for c in binaryString:
        num += eval(c)*(2**(l-1))
        l -= 1
    return num

def binaryToHex(binaryString):
    l = len(binaryString)
    ll = l%4
    for i in range(0,4-ll):
        binaryString = "0"+binaryString

    s = ''
    for i in range(0,len(binaryString),4):
        binary = binaryToDecimal(binaryString[i:i+4])
        if binary>10:
            s += chr(ord('A')+binary-10)
        elif binary>0:
            s += str(binary)

    return s


binary = input("请输入一个二进制字符串：")
print(binaryToDecimal(binary))

print(binaryToHex(binary))